<script setup>
  import { ref, reactive } from 'vue'
  import { getOrderDocListApi } from '@/server/order'
  import orderList from '@/components/orderList/orderList.vue'

  // // 标签索引值
  const tabIndex = ref(0)

  // // 标签页数据
  const orderTabs = reactive([
    { label: '问医生', type: 1, rendered: true },
    { label: '极速问诊', type: 2, rendered: false },
    { label: '开药问诊', type: 3, rendered: false },
  ])

  // // 标签页切换
  function onTabChangefn(item, index) {
    tabIndex.value = index
    orderTabs[tabIndex.value].rendered = true
    // getOrderList()
  }

  // // 页码
  // const pageCurrent = ref(1)

  // // 页数
  // const pageSize = ref(10)

  // // 获取数据
  // async function getOrderList() {
  //   if (orderTabs[tabIndex.value].rendered === true) return
  //   const { data } = await getOrderDocListApi({
  //     current: pageCurrent.value,
  //     pageSize: pageSize.value,
  //     type: orderTabs[tabIndex.value].type,
  //   })
  //   // console.log(orderTabs.value[tabIndex.value].list)
  //   orderTabs[tabIndex.value].list.push(...data.data.rows)
  //   orderTabs[tabIndex.value].rendered = true
  // }
  // getOrderList()
</script>
<template>
  <view class="consult-page">
    <view class="consult-status-tabs">
      <tab-curcom :list="orderTabs" @click="onTabChangefn"></tab-curcom>
    </view>

    <!-- 订单列表 -->
    <view
      v-for="(item, index) in orderTabs"
      :key="item.type"
      v-show="tabIndex === index"
    >
      <order-list
        v-if="item.rendered"
        :type="orderTabs[tabIndex].type"
      ></order-list>
    </view>
  </view>
</template>

<style lang="scss">
  @import './index.scss';
</style>
